package com.prs.crm.dao.online.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.online.VoteItemDao;
import com.prs.crm.domain.online.VoteItem;

public class VoteItemDaoImpl extends BaseDaoImpl<VoteItem> implements VoteItemDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<VoteItem> getVoteItem(final String[] name) {
		Criteria criteria=this.getSession().createCriteria(VoteItem.class);
		criteria.add(Restrictions.in("name", name));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<VoteItem> getAllVoteItem() {
		Criteria criteria=this.getSession().createCriteria(VoteItem.class);
		return criteria.list();
	}

	@Override
	public VoteItem getVoteItems(Integer id) {
		Criteria criteria=this.getSession().createCriteria(VoteItem.class);
		criteria.add(Restrictions.eq("id", id));
		return (VoteItem) criteria.list().get(0);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<VoteItem> getVoteItemById(Integer id) {
		Criteria criteria=this.getSession().createCriteria(VoteItem.class);
		criteria.add(Restrictions.eq("vote.id", id));
		return  criteria.list();
	}

}
